package com.proyecto.spv.client.view;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.HasClickHandlers;

public class LoginView extends Composite {
	private TextBox textBoxUsuario;
	private PasswordTextBox textBoxPassword;
	private Button buttonLogin;

	public LoginView() {
		
		VerticalPanel verticalPanel = new VerticalPanel();
		initWidget(verticalPanel);
		verticalPanel.setHeight("292px");
		
		HorizontalPanel horizontalPanel = new HorizontalPanel();
		verticalPanel.add(horizontalPanel);
		horizontalPanel.setSize("449px", "38px");
		
		Label lblSistemaDePlanilla = new Label("Sistema de Planilla Virtual");
		lblSistemaDePlanilla.setStyleName("gwt-Label-Title");
		lblSistemaDePlanilla.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		horizontalPanel.add(lblSistemaDePlanilla);
		horizontalPanel.setCellVerticalAlignment(lblSistemaDePlanilla, HasVerticalAlignment.ALIGN_MIDDLE);
		
		DecoratorPanel decoratorPanel = new DecoratorPanel();
		verticalPanel.add(decoratorPanel);
		verticalPanel.setCellHorizontalAlignment(decoratorPanel, HasHorizontalAlignment.ALIGN_CENTER);
		
		FlexTable flexTable = new FlexTable();
		decoratorPanel.setWidget(flexTable);
		flexTable.setSize("313px", "89px");
		
		Label label = new Label("Inciar Sesion");
		label.setStyleName("gwt-Label-Title");
		label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		flexTable.setWidget(0, 0, label);
		
		Label label_1 = new Label("Usuario:");
		label_1.setStyleName("gwt-label-normal");
		flexTable.setWidget(1, 0, label_1);
		
		textBoxUsuario = new TextBox();
		flexTable.setWidget(1, 1, textBoxUsuario);
		
		Label label_2 = new Label("Contrase\u00F1a:");
		label_2.setStyleName("gwt-label-normal");
		flexTable.setWidget(2, 0, label_2);
		
		textBoxPassword = new PasswordTextBox();
		flexTable.setWidget(2, 1, textBoxPassword);
		textBoxPassword.setWidth("159px");
		
		buttonLogin = new Button("Inciar Sesion");
//		buttonLogin.addClickHandler(new ClickHandler() {
//			public void onClick(ClickEvent event) {
//			}
//		});
		flexTable.setWidget(3, 1, buttonLogin);
		flexTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
		flexTable.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
		flexTable.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_TOP);
			
	}
	
	public HasClickHandlers getLoginButton(){
		return buttonLogin;
	}

	public Widget asWidget(){
		
		return this;
	}
}
